﻿@using NFine.Domain._03_Entity.Weixin
@using NFine.Domain._02_ViewModel
@{
    ViewBag.Title = "积分换购";
    Layout = "~/Areas/WeiXinAreas/Views/Shared/_LayoutWeui.cshtml";
}
<style>
    .weui-cells {
        margin-top: .5rem;
    }

    .weui-btn {
        border-radius: 0;
    }
</style>
<div class="weui-cells" style="background-color:#35a4fe;">
    <div class="weui-cell">
        <div class="weui-cell__bd">
            <div style="padding-left:1rem; padding-right:1rem;">
                <div style="width:50%; float:left; margin-top:.5rem;">
                    <div style="font-size:.7rem; color:#fff;">积分余额：</div>
                    <div style="color:#fdcb07; font-size:1rem;" id="pjint">@ViewData["hgInt"]</div>
                </div>
                <div style="clear:both;"></div>
                <div style="font-size:.4rem;margin-top:.5rem; color:#eee;">注：积分为平台消费后产生的收益</div>
            </div>
        </div>
    </div>
</div>
<div class="weui-cells">
    <a class="weui-cell weui-cell_access" href="~/WeiXinAreas/Main/HGList">
        <div class="weui-cell__hd"><img src="~/Content/M/img/gn_withdrawal.png" style="width:1.5rem" /></div>
        <div class="weui-cell__bd">
            积分换购记录
        </div>
        <div class="weui-cell__ft">
        </div>
    </a>
</div>

@if (ViewData["usertype"].ToString() != "zhongzhuan"&&ViewData["hgInt"].ToString()!="0.00")
{
    <form id="form1">
        <div class="weui-cells__title">积分换购</div>
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">                
                <div class="weui-cell__hd"><label for="" class="weui-label">中转中心</label></div>
                <div class="weui-cell__bd">
                    <select id="F_TransferCenterId" class="form-control required">
                        <option value="">选择中转中心</option>
                        @if (ViewData["TransferCenterList"] != null)
                        {
                            foreach (var entity in (List<View_User_Zhzh>)ViewData["TransferCenterList"])
                            {
                                @*<option value="@entity.F_Id" data-jf-num="@entity.jfcount">@entity.F_RealName</option>*@
                                <option value="@entity.F_Id">@entity.F_RealName</option>
                            }
                        }

                    </select>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="" class="weui-label">换购积分</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input digits" type="number" placeholder="请输入积分数量"  id="jlint" name="jlint">
                </div>
                @*<div class="weui-cell__ft">
                    <i class="weui-icon-success"></i>
                </div>*@
            </div>
            @*<div class="weui-cell">
                <div class="weui-cell__hd"><label for="" class="weui-label">备&nbsp;&nbsp;&nbsp;&nbsp;注</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" value="" placeholder="有什么需要提醒的" name="F_Remark" id="F_Remark">
                </div>
            </div>*@
        </div>
        <a href="javascript:submit();" class="weui-btn weui-btn_primary" style="margin-top:.5rem;background-color:#35a4fe;">积分换购<i class="weui-loading" style="display:none;"></i></a>
    </form>
                    }
<div style="height:60px;"></div>
<div class="weui-tabbar" style="position:fixed;">
    <a href="~/WeiXinAreas/Main/Index" class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img src="~/Content/M/img/home@2x.png" alt="">
        </div>
        <p class="weui-tabbar__label">首页</p>
    </a>
    <a href="~/WeiXinAreas/Main/NewsList" class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img src="~/Content/M/img/kecheng@2x.png" alt="">
        </div>
        <p class="weui-tabbar__label">新闻</p>
    </a>
    <a href="~/WeiXinAreas/Main/Ponser" class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img src="~/Content/M/img/person@2x_.png" alt="">
        </div>
        <p class="weui-tabbar__label">个人</p>
    </a>
</div>
@section footScript
{
    <script type="text/javascript">

        function setInvalid(str) {
            var a = str;
            $.alert(str);
        }
        function submit() {
            if (!$("#F_TransferCenterId").val())
            {
                $.alert('请选择中转中心！', "error");
                return;
            }
            var val=$("#jlint").val();
            if (!val||val.length==0)
            {
                $.alert('请输入积分消耗数量！', "error");
                return;
            }
            var vale = parseFloat(val);
            if (!vale || vale <= 0 || vale > parseFloat($("#pjint").text()))
            {
                $.alert('消耗数量不能小于0或超过当前积分！', "error");
                return;
            }
            var postData = { 'uid': ''+$("#F_TransferCenterId").val()+'', 'pjint': $("#pjint").text(), 'jlint': vale };

            $(".weui-loading").show();
            $.ajax({
                url: "/BizManage/HuangouIntegral/SubmitForm",
                data: postData,
                dataType: 'json',
                type: 'post',
                success: function (_data) {
                    //$.alert(_data);
                    location.replace("HG");
                }
            });
        }
    </script>
}
